package naves;

import java.awt.Point;
import java.util.Random;

import javax.swing.ImageIcon;

import logica.SkyNet;
import balas.BalaEnCaida;

public class Haaslich extends Enemiga {
	
	protected int frecuencia;
	
	public Haaslich (SkyNet ia,int i) {
		this.setIcon(new ImageIcon(getClass().getClassLoader().getResource("images/HAASLICH.gif")));
		this.setSize(28,28);
		this.velocidad = 3;
		this.potencia = 100;
		this.vida = 50;
		this.movimiento = new Point(0,velocidad);
		this.lord = ia;	
		this.frecuencia = 80;
		this.esEnemigo=true;
		this.esEnemigoFinal=false;
		this.puntaje=75;
		this.esTiro=false;
		if(i==1)
			this.esPowerUp=true;
		else
			this.esPowerUp=false;
	}
	
	/**
	 * metodo utilizado para que una nave enemiga dispare, con su tipo particular de bala
	 */
	public void disparar() {
		Random rn = new Random(System.currentTimeMillis());
		if( rn.nextInt(this.frecuencia) == 0 ) {
			BalaEnCaida bec = new BalaEnCaida(this.lord);			
			int nx = this.getLocation().x + ((this.getWidth() - bec.getWidth())/2);
			int ny = this.getLocation().y + ((this.getHeight() - bec.getHeight())/2);
			bec.setLocation(nx, ny);
			this.lord.agregarObjeto(bec);
		}
	}
	
	public void mover() {
		if(this.esPowerUp==false)
			disparar();
		super.mover();
	}

	@Override
	public void reLocation() {
		Random rnd = new Random(System.currentTimeMillis());
		this.setLocation(rnd.nextInt(this.lord.getJuego().getWidth()), -1*this.getHeight());		
	}
	
}
